/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.diamondsys.embrapa;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Pablo
 */
@Entity
@Table(name = "sac")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Sac.findAll", query = "SELECT s FROM Sac s ORDER BY s.dataCadastro ASC"),
    @NamedQuery(name = "Sac.findById", query = "SELECT s FROM Sac s WHERE s.id = :id"),
    @NamedQuery(name = "Sac.findByDataCadastro", query = "SELECT s FROM Sac s WHERE s.dataCadastro = :dataCadastro"),
    @NamedQuery(name = "Sac.findByAssunto", query = "SELECT s FROM Sac s WHERE s.assunto = :assunto")})
public class Sac implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "data_cadastro")
    @Temporal(TemporalType.DATE)
    private Date dataCadastro;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "assunto")
    private String assunto;
    @JoinColumn(name = "tb_inst_cod_instituicao", referencedColumnName = "cod_instituicao")
    @ManyToOne(optional = false)
    private TbInst tbInstCodInstituicao;

    public Sac() {
    }

    public Sac(Integer id) {
        this.id = id;
    }

    public Sac(Integer id, Date dataCadastro, String assunto) {
        this.id = id;
        this.dataCadastro = dataCadastro;
        this.assunto = assunto;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDataCadastro() {
        return dataCadastro;
    }

    public void setDataCadastro(Date dataCadastro) {
        this.dataCadastro = dataCadastro;
    }

    public String getAssunto() {
        return assunto;
    }

    public void setAssunto(String assunto) {
        this.assunto = assunto;
    }

    public TbInst getTbInstCodInstituicao() {
        return tbInstCodInstituicao;
    }

    public void setTbInstCodInstituicao(TbInst tbInstCodInstituicao) {
        this.tbInstCodInstituicao = tbInstCodInstituicao;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sac)) {
            return false;
        }
        Sac other = (Sac) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.diamondsys.embrapa.Sac[ id=" + id + " ]";
    }
    
}
